package GameLogic
{
	import BasicEngine.Dispatcher;
	import flash.display.Bitmap;
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.Shape;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.net.URLRequest;
	import LoadUnit.LoadManager;
	
	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class Game
	{
		public static var MainCanvas:Sprite;
		public static var MainTimer:Timer;			
		public static var Pause:Boolean;
		public static var Width:int;
		public static var Height:int;		
		public static var MainStage:Stage;
		
		public function Game()
		{
		}
		
		//初始化
		public static function Init(_main:Sprite,_width:int,_height:int):void
		{
			Pause = true;
			Dispatcher.Init();
			Width = _width;
			Height = _height;
			MainCanvas = _main;
			
			MainTimer = new Timer(20,0); //20 毫秒计时一次
			MainTimer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent) :void
			{
				Update();
			});		
		}
		
		public static function Update():void
		{
			if (!Pause)
			{
				Dispatcher.ExecuteUpdate();
				LoadManager.Update();
			}
		}
		
		//游戏启动，启动游戏调度
		public static function Star():void
		{
			MainTimer.start();
			Pause = false;
		}
	}
}